﻿@model DynamicForm.Models.Metadata.MetaTable

@{
    ViewBag.Title = "CreateTable";
}

<script type="text/javascript">

function ajaxValidate() {
  return $('form').validate().form();
}

function getGbPostSuccess(ajaxContext){
  // .... it is not necessary to do anything here.
}
function showFaliure(ajaxContext){
   // handle failure
}
//$('#dialog-form').dialog();
$(function () {
    $("#dialog").dialog();
});
    </script>

<h2>CreateTable</h2>
<div id="dialog-form" title="Create new field">
  @using (Ajax.BeginForm(new AjaxOptions()))
   {
  <fieldset>
    <label for="name">Name</label>
    @Html.TextBoxFor(model => model.TableField.Name)
    <label for="text">Data Type</label>
    @Html.TextBoxFor(model => model.TableField.DataType)
    <label for="password">Options</label>
    @Html.TextBoxFor(model => model.TableField.Options)
  </fieldset>
  }
</div>
@using (Ajax.BeginForm(new AjaxOptions()))
{
    <div id="divUpdate">
    <span>Name:</span>
    @Html.TextBoxFor(model => model.Name)
        <br />
        <input id="File1" name="File1" type="file" />
        <button id="btnAdd">Create new field</button>
    <table id="Fields" name="Fields">
        <tr>
            <th>Name</th>
            <th>Data type</th>
            <th>Length</th>
            <th>Options</th>
            <th></th>
        </tr>
        @foreach (DynamicForm.Models.Metadata.MetaTableField field in Model.Fields)
        {
            <tr>
                <td>@field.Name</td>
                <td>@field.DataType</td>
                <td>@field.FieldLength</td>
                <td>@field.Options</td>
                <td>
                    <input id="btnEdit" type="submit" value="Edit" />   
                    <input id="btnDelete" type="submit" value="Del" />   
                </td>
            </tr>
        }
    </table>
    <br />
    <input id="Submit1" type="submit" value="Save" />   
    </div>
}